package Utility
{
	import flash.events.MouseEvent;
	import mx.containers.Box;
	import mx.containers.DividedBox;
	import mx.controls.Image;

	public class HDividerBox extends Box
	{
		[Embed(source='images/arrow_down.gif')]
		public static const DividerIcon_left:Class;

		[Embed(source='images/arrow_up.gif')]
		public static const DividerIcon_right:Class;

		private var image:Image=new Image();
		private var bOpened:Boolean=false;

		private var dividbox:DividedBox=null;

		public function HDividerBox()
		{
			super();
			this.width=72;
			this.height=12;
			this.clipContent=true;
			image.width=72;
			image.height=12;
			this.toolTip="点击图标可以隐藏或显示功能卡";
			this.addChild(image);
			//我这个是在一个HdividedBox中，其默认对dividerbox进行了旋转，所以需要旋转回来。  
			image.rotation=360;
			this.buttonMode=true;
			this.addEventListener(MouseEvent.CLICK, onMouseClick);
		}

		override protected function createChildren():void
		{
			super.createChildren();
			dividbox=this.parent.parent.parent as DividedBox;
			image.source=DividerIcon_left;
		}


		public function onMouseClick(event:MouseEvent):void
		{
			if (bOpened)
			{
				image.source=DividerIcon_right;
				dividbox.getChildAt(1).height=0;
				bOpened=false;
			}
			else
			{
				bOpened=true;
				image.source=DividerIcon_left;
				dividbox.getChildAt(1).height=210;
			}
		}
	}
}

